package com.ruoyi.draw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.draw.domain.NovelType;
import com.ruoyi.draw.service.INovelTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * NovelTypeController
 * 
 * @author Locek
 * @date 2025-10-25
 */
@RestController
@RequestMapping("/novel/type")
public class NovelTypeController extends BaseController
{
    @Autowired
    private INovelTypeService novelTypeService;

    /**
     * 查询NovelType列表
     */
    @PreAuthorize("@ss.hasPermi('novel:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(NovelType novelType)
    {
        startPage();
        List<NovelType> list = novelTypeService.selectNovelTypeList(novelType);
        return getDataTable(list);
    }

    /**
     * 导出NovelType列表
     */
    @PreAuthorize("@ss.hasPermi('novel:type:export')")
    @Log(title = "NovelType", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NovelType novelType)
    {
        List<NovelType> list = novelTypeService.selectNovelTypeList(novelType);
        ExcelUtil<NovelType> util = new ExcelUtil<NovelType>(NovelType.class);
        util.exportExcel(response, list, "NovelType数据");
    }

    /**
     * 获取NovelType详细信息
     */
    @PreAuthorize("@ss.hasPermi('novel:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(novelTypeService.selectNovelTypeById(id));
    }

    /**
     * 新增NovelType
     */
    @PreAuthorize("@ss.hasPermi('novel:type:add')")
    @Log(title = "NovelType", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NovelType novelType)
    {
        return toAjax(novelTypeService.insertNovelType(novelType));
    }

    /**
     * 修改NovelType
     */
    @PreAuthorize("@ss.hasPermi('novel:type:edit')")
    @Log(title = "NovelType", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NovelType novelType)
    {
        return toAjax(novelTypeService.updateNovelType(novelType));
    }

    /**
     * 删除NovelType
     */
    @PreAuthorize("@ss.hasPermi('novel:type:remove')")
    @Log(title = "NovelType", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(novelTypeService.deleteNovelTypeByIds(ids));
    }
}
